import 'package:flutter/material.dart';
import '/components/page/common.dart';
import './widgets/chat_list_item.dart';
import '/model/chat_list_model.dart';
import '/mock/chat_list.dart';
import '/components/actions/search.dart';
import '/components/actions/pop_menu.dart';

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return CommonPage(
      title: '微信',
      actions: [const SearchAction(), popupMenuWidget()],
      child: Container(
          color: Colors.white,
          child: const ChatListWidget()
      ),
    );
  }
}


// 微信聊天列表
class ChatListWidget extends StatefulWidget {
  const ChatListWidget({super.key});

  @override
  State<ChatListWidget> createState() => _ChatListWidgetState();
}

class _ChatListWidgetState extends State<ChatListWidget> {

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
        itemCount: chatListMockArr.length,
        shrinkWrap: true,
        padding: const EdgeInsets.all(10.0),
        itemBuilder: (BuildContext context, int index) {
          final item = ChatListItemModel.fromJson(chatListMockArr[index]);
          return ChatListItem(model: item);
        }
    );
  }
}